
package net.tutwiz.bindingBeans;

import java.util.List;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import net.tutwiz.model.Tutorial;
import net.tutwiz.persistence.TutorialPersistenceManager;


/**
 *
 * @author vind
 */
@ManagedBean(name = "tutorialBean")
@ApplicationScoped
public class TutorialBindingBean {
    
    public List<Tutorial> getTutorials() {
        TutorialPersistenceManager tutorialPM = new TutorialPersistenceManager();
        List<Tutorial> tutorials = tutorialPM.getAll();

        return tutorials;
    }
    
    public void updateTutorial(Tutorial t) {
        TutorialPersistenceManager tutorialPM = new TutorialPersistenceManager();
        tutorialPM.update(t);
    }
    
    public void createNewTutorial() {
        TutorialPersistenceManager tutorialPM = new TutorialPersistenceManager();
        tutorialPM.save(new Tutorial("insert your title here", "Describe your tutorial here"));
    }
}
